home *** CD-ROM | disk | FTP | other *** search
/ Shareware Extravaganza 7 / Shareware Extravaganza 8 (Most Significant Bits) (Disc 7).iso / win95b / wb32-96a.zip / FILEMENU.MN_ < prev    next >
Text File  |  1995-12-14  |  19KB  |  452 lines

  1.           editor="notepad.exe"    ;Default editor
  2.           ; Common menu for all file types
  3.           ;First figure out where filemenu.dll is installed via registry lookup
  4.       ErrorMode(@OFF)
  5.           wbdir=RegQueryValue(@REGMACHINE,"SOFTWARE\Wilson WindowWare\WinBatch\CurrentVersion")
  6.           if wbdir==0 
  7.              wbdir=RegQueryValue(@REGMACHINE,"SOFTWARE\Wilson WindowWare\WinBatch Compiler\CurrentVersion")
  8.           endif
  9.           ErrorMode(@CANCEL)
  10.           if wbdir==0 then Display(5,"Error","Registry entries missing.  Re-install WinBatch")
  11.       homedir=strcat(wbdir,"system\")
  12.  
  13.           ;Next see if WinEdit is lurking about via registry lookup
  14.       ErrorMode(@OFF)
  15.           WinEdit=strcat(RegQueryValue(@REGMACHINE,"SOFTWARE\Wilson WindowWare\WinEdit\CurrentVersion"),"WinEdit.exe")
  16.           ErrorMode(@CANCEL)
  17.           if WinEdit==0    ;No?  Try path
  18.              WinEdit=FileLocate("WINEDIT.EXE")
  19.              if WinEdit=="" then WinEdit=editor
  20.           endif
  21.  
  22.           inifile=strcat(DirWindows(0),"FileMenu.ini")
  23.           if !FileExist(inifile) then inifile=strcat(homedir,"FileMenu.ini")
  24.           commonmenu="FileMenu for all filetypes.mnw"
  25.           defaultmenu="FileMenu for misc filetypes.mnw"
  26.  
  27. Two Explorers, side by side ; Your dual window file manager
  28.         a=IntControl(31,0,0,0,0)  ;return list of ids of explorer windows
  29.         c=ItemCount(a,@TAB)
  30.         switch c
  31.            case 0
  32.               run("explorer.exe",strcat("/n,/e,",DirGet()))
  33.               while FindWindow("ExploreWClass")==""    ;wait for it to come up
  34.                 Yield
  35.               end while
  36.               ;Fall into case 1
  37.  
  38.            case 1
  39.               run("explorer.exe",strcat("/n,/e,",DirGet()))
  40.               break
  41.            case c       ; 2 or more
  42.               break
  43.         endswitch
  44.         d=1
  45.         while c<2 && d<500
  46.            a=IntControl(31,0,0,0,0)
  47.            c=ItemCount(a,@TAB)
  48.            d=d+1
  49.         endwhile
  50.         if c<2 then exit
  51.         id1=ItemExtract(1,a,@TAB)
  52.         id2=ItemExtract(2,a,@tab)
  53.         WinPlaceSet(@NORMAL,id2,"500 0 1000 900")
  54.         WinShow(id2)
  55.         Yield
  56.         Yield
  57.         WinPlaceSet(@NORMAL,id1,"0 0 500 900")
  58.         WinShow(id1)
  59.      
  60. Open With ... ; Choose an application to view or edit the selected file.
  61.  
  62.  &Browser (binary file viewer)  ; View any file in binary format.
  63.         file = CurrFilePath()
  64.         If !(FileExist(file)) Then file = ""
  65.         Else If FileExtension(file) == "" Then file = StrCat(file, ".")
  66.         Run("browser.exe", FileNameShort(file))     
  67.  &Notepad  ; Modify small plain text files.
  68.         file = CurrFilePath()
  69.         If !(FileExist(file)) Then file = ""
  70.         Else If FileExtension(file) == "" Then file = StrCat(file, ".")
  71.         Run("notepad.exe", file)
  72.  &MSPaint (bitmap) ; View and Modify bitmaps
  73.          file = CurrFilePath()
  74.          If !(FileExist(file)) Then file = ""
  75.               Else If FileExtension(file) == "" Then file = StrCat(file, ".")
  76.          bmpfile = strlower(FileExtension(file))
  77.          If bmpfile != "bmp"
  78.               Message("Error","Select a bitmap file and try again.")
  79.               Exit
  80.          EndIf          
  81.          rkey=RegOpenKey(@REGMACHINE,"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths")
  82.          mspaintexe=RegQueryValue(rkey,"MSPAINT.EXE")
  83.          RegCloseKey(rkey)
  84.          Run(mspaintexe,file)
  85.  &Wordpad (text and graphics) ; Modify WORD, RTF, plain text files. Can contain bitmaps, too.
  86.          file = CurrFilePath()
  87.          If !(FileExist(file)) Then file = ""
  88.               Else If FileExtension(file) == "" Then file = StrCat(file, ".")
  89.          rkey=RegOpenKey(@REGMACHINE,"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths")
  90.          wordpadexe=RegQueryValue(rkey,"WORDPAD.EXE")
  91.          RegCloseKey(rkey)
  92.          Run(wordpadexe,file)
  93.  Win&Edit (text) ; Open file with WinEdit
  94.         f = CurrFilePath()
  95.         If !(FileExist(f)) Then f = ""
  96.         Else If FileExtension(f) == "" Then f = StrCat(f, ".")
  97.         Run(WinEdit, f)
  98.  
  99.      
  100. File Operations
  101.  
  102.  File/Folder size    ;Sum sizes of all highlighted files and folders
  103.         
  104.         tot = FileSize(FileItemize(""))
  105.         sub1 = DirItemize("")
  106.         totdir=0
  107.         level=1
  108.         dir1=DirGet()
  109.         
  110.         numdir1 = ItemCount(sub1, @tab)
  111.         index1 = 0
  112.   
  113.         :dsloop
  114.         If index%level% == numdir%level% Then Goto upalevel
  115.         index%level% = index%level% + 1
  116.         DirChange(StrCat(dir%level%, ItemExtract(index%level%, sub%level%, @tab)))
  117.         
  118.         totdir=totdir+1
  119.         tot = tot + FileSize(FileItemize("*.*"))
  120.         level = level + 1
  121.         dir%level% = DirGet()
  122.         sub%level% = DirItemize("*.*")
  123.         numdir%level% = ItemCount(sub%level%, @tab)
  124.         index%level% = 0
  125.         goto dsloop
  126.   
  127.         :upalevel
  128.         drop(dir%level%,sub%level%,index%level%,numdir%level%)
  129.         level=level-1
  130.         if level!=0 then goto dsloop
  131.  
  132.         ; -----------
  133.         ; Termination
  134.         ; -----------
  135.         
  136.         If StrLen(tot) < 9 Then tot = StrCat(StrFill("", 9 - StrLen(tot)), tot)
  137.         tot = StrCat(StrSub(tot,1,3),",",StrSub(tot,4,3),",",StrSub(tot,7,3))
  138.         tot = StrTrim(tot)
  139.         If StrSub(tot, 1, 1) == "," Then tot = StrSub(tot, 2, StrLen(tot) - 1)
  140.         tot = StrTrim(tot)
  141.         If StrSub(tot, 1, 1) == "," Then tot = StrSub(tot, 2, StrLen(tot) - 1)
  142.         tot = StrTrim(tot)
  143.         Message("%totdir% Subdirectories included", "Total size %tot% bytes.")
  144.  
  145.  Print (with Notepad)    ;Print text-type file with notepad on default printer
  146.     Run("notepad.exe",strcat("/p ",FileCurrPath())
  147.  Associate        ;Associate this type of file with an application
  148.         a=strlower(FileExtension(CurrentFile()))
  149.         b=AskFileName("Associate %a% files with","C:\","Executable Files|*.exe;*.com;*.bat;*.pif|All Files|*.*|","",1)
  150.     
  151.         rkey=RegOpenKey(@REGCLASSES,"")
  152.         ErrorMode(@OFF)
  153.         RegDeleteKey(rkey,".%a%")
  154.         ErrorMode(@CANCEL)
  155.         RegSetValue(rkey, ".%a%", "%a%_auto_file")
  156.         RegSetValue(rkey,"%a%_auto_file\shell\open\command",strcat('"',b,'" "%%1"'))
  157.         RegClosekey(rkey)
  158.  File Attributes    ;View file attributes
  159.         files = FileItemize("")
  160.         numfiles = ItemCount(files,@TAB)
  161.         While numfiles == 1
  162.         file = CurrentFile()
  163.         result = FileAttrGet(file)
  164.         If StrLen(file) > 30
  165.              fileindialog = StrSub(file,1,30)
  166.           
  167.              fileindialog = StrCat(fileindialog," ...")
  168.         Else 
  169.              fileindialog = file
  170.         EndIf
  171.      
  172.         readonly = 2
  173.         archive = 2
  174.         system = 2
  175.         hidden = 2
  176.         If StrSub(result,1,1) == "R" Then readonly = "3"
  177.         If StrSub(result,2,1) == "A" Then archive = "3"
  178.         If StrSub(result,3,1) == "S" Then system = "3"
  179.         If StrSub(result,4,1) == "H" Then hidden = "3"
  180.  
  181.                FileAttributesFormat=`WWWDLGED,5.0`
  182.                
  183.                FileAttributesCaption=`File Attributes`
  184.                FileAttributesX=7
  185.                FileAttributesY=25
  186.                FileAttributesWidth=199
  187.                FileAttributesHeight=101
  188.                FileAttributesNumControls=17
  189.                
  190.                FileAttributes01=`110,86,36,DEFAULT,PUSHBUTTON,DEFAULT,"&Cancel",0`
  191.                FileAttributes02=`42,18,38,DEFAULT,STATICTEXT,DEFAULT,"Read Only"`
  192.                FileAttributes03=`126,18,36,DEFAULT,STATICTEXT,DEFAULT,"System"`
  193.                FileAttributes04=`84,18,36,DEFAULT,STATICTEXT,DEFAULT,"Archive"`
  194.                FileAttributes05=`168,18,36,DEFAULT,STATICTEXT,DEFAULT,"Hidden"`
  195.                FileAttributes06=`56,86,36,DEFAULT,PUSHBUTTON,DEFAULT,"&OK",1`
  196.                FileAttributes07=`2,54,36,DEFAULT,STATICTEXT,DEFAULT,"On"`
  197.                FileAttributes08=`2,36,36,DEFAULT,STATICTEXT,DEFAULT,"Off"`
  198.                FileAttributes09=`2,4,194,DEFAULT,STATICTEXT,DEFAULT,"Set File Attributes for => %fileindialog% "`
  199.                FileAttributes10=`42,36,36,DEFAULT,RADIOBUTTON,readonly,"",2`
  200.                FileAttributes11=`42,54,36,DEFAULT,RADIOBUTTON,readonly,"",3`
  201.                FileAttributes12=`166,54,36,DEFAULT,RADIOBUTTON,hidden,"",3`
  202.                FileAttributes13=`84,36,36,DEFAULT,RADIOBUTTON,archive,"",2`
  203.                FileAttributes14=`84,54,36,DEFAULT,RADIOBUTTON,archive,"",3`
  204.                FileAttributes15=`166,36,36,DEFAULT,RADIOBUTTON,hidden,"",2`
  205.                FileAttributes16=`126,36,36,DEFAULT,RADIOBUTTON,system,"",2`
  206.                FileAttributes17=`126,54,36,DEFAULT,RADIOBUTTON,system,"",3`
  207.                
  208.                ButtonPushed=Dialog("FileAttributes")
  209.  
  210.  
  211.  
  212.            Select buttonpushed
  213.           
  214.                Case 0
  215.                     Break
  216.                     
  217.                Case 1
  218.  
  219.                     first = ""
  220.                     second = ""
  221.                     third = ""
  222.                     fourth = ""
  223.                     If readonly == 2 Then first = "r"
  224.                     If archive == 2 Then second = "a"
  225.                     If system == 2 Then third = "s"
  226.                     If hidden == 2 Then fourth = "h"
  227.                     If readonly == 3 Then first = "R"
  228.                     If archive == 3 Then second = "A"
  229.                     If system == 3 Then third = "S"
  230.                     If hidden == 3 Then fourth = "H"
  231.  
  232.                     
  233.                     
  234.                     
  235.                     attributes = StrCat( first, second, third, fourth )
  236.                     FileAttrSet(file, attributes)
  237.                     break
  238.            End Select
  239.                 
  240.  
  241.      Exit
  242.      EndWhile
  243.  
  244.      ;Set Attributes: Selected Files
  245.  
  246.      displayfiles = files
  247.      readonly = 1
  248.      archive = 1
  249.      system = 1
  250.      hidden = 1
  251.                AttribFormat=`WWWDLGED,5.0`
  252.                
  253.                AttribCaption=`Attributes`
  254.                AttribX=6
  255.                AttribY=25
  256.                AttribWidth=201
  257.                AttribHeight=101
  258.                AttribNumControls=22
  259.                
  260.                Attrib01=`110,86,36,DEFAULT,PUSHBUTTON,DEFAULT,"&Cancel",0`
  261.                Attrib02=`42,18,38,DEFAULT,STATICTEXT,DEFAULT,"Read Only"`
  262.                Attrib03=`126,18,36,DEFAULT,STATICTEXT,DEFAULT,"System"`
  263.                Attrib04=`84,18,36,DEFAULT,STATICTEXT,DEFAULT,"Archive"`
  264.                Attrib05=`168,18,36,DEFAULT,STATICTEXT,DEFAULT,"Hidden"`
  265.                Attrib06=`2,34,38,DEFAULT,STATICTEXT,DEFAULT,"No Change"`
  266.                Attrib07=`2,70,36,DEFAULT,STATICTEXT,DEFAULT,"On"`
  267.                Attrib08=`2,52,36,DEFAULT,STATICTEXT,DEFAULT,"Off"`
  268.                Attrib09=`42,34,36,DEFAULT,RADIOBUTTON,readonly,"",1`
  269.                Attrib10=`42,52,36,DEFAULT,RADIOBUTTON,readonly,"",2`
  270.                Attrib11=`42,70,36,DEFAULT,RADIOBUTTON,readonly,"",3`
  271.                Attrib12=`84,34,36,DEFAULT,RADIOBUTTON,archive,"",1`
  272.                Attrib13=`84,52,36,DEFAULT,RADIOBUTTON,archive,"",2`
  273.                Attrib14=`84,70,36,DEFAULT,RADIOBUTTON,archive,"",3`
  274.                Attrib15=`126,34,36,DEFAULT,RADIOBUTTON,system,"",1`
  275.                Attrib16=`126,52,36,DEFAULT,RADIOBUTTON,system,"",2`
  276.                Attrib17=`126,70,36,DEFAULT,RADIOBUTTON,system,"",3`
  277.                Attrib18=`168,34,36,DEFAULT,RADIOBUTTON,hidden,"",1`
  278.                Attrib19=`168,52,36,DEFAULT,RADIOBUTTON,hidden,"",2`
  279.                Attrib20=`168,70,36,DEFAULT,RADIOBUTTON,hidden,"",3`
  280.                Attrib21=`58,2,130,DEFAULT,STATICTEXT,DEFAULT,"Set Attributes for Selected Files"`
  281.                Attrib22=`56,86,36,DEFAULT,PUSHBUTTON,DEFAULT,"&OK",1`
  282.                
  283.                ButtonPushed=Dialog("Attrib")
  284.                
  285.  
  286.  
  287.  
  288.           Select buttonpushed
  289.           
  290.                Case 0
  291.                     Break
  292.                     
  293.                Case 1
  294.  
  295.                     first = ""
  296.                     second = ""
  297.                     third = ""
  298.                     fourth = ""
  299.                     If readonly == 2 Then first = "r"
  300.                     If archive == 2 Then second = "a"
  301.                     If system == 2 Then third = "s"
  302.                     If hidden == 2 Then fourth = "h"
  303.                     If readonly == 3 Then first = "R"
  304.                     If archive == 3 Then second = "A"
  305.                     If system == 3 Then third = "S"
  306.                     If hidden == 3 Then fourth = "H"
  307.  
  308.                     
  309.                     
  310.                     
  311.                     attributes = StrCat( first, second, third, fourth )
  312.                     FileAttrSet(files, attributes)
  313.                     break
  314.            End Select
  315.       Exit                              
  316.  
  317.  
  318.  DOS &Copy  ; Like the good, old, DOS COPY command.
  319.        s = StrTrim(FileItemize(""))
  320.        s=StrReplace(s,@tab,"|")
  321.        If s == "" Then Message("Copy Error", "No files selected")
  322.        Then Exit
  323.        If ItemCount(s, "|") == 1 Then t = s
  324.        Else t = ""
  325.        t = AskLine("Copy", StrCat(s, @CRLF, @CRLF, "to"), t)
  326.        If t == "" Then Message("Copy Error", "Cannot copy to null file name")
  327.                Then Exit
  328.        FileCopy(s, t, @TRUE)
  329.  
  330.  DOS &Rename  ;Like the good, old DOS RENAME command.
  331.        s = StrTrim(FileItemize(""))
  332.        s=StrReplace(s,@tab,"|")
  333.        If s == "" Then Message("Rename Error", "No files selected")
  334.        Then Exit
  335.        If ItemCount(s, "|") == 1 Then t = s
  336.        Else t = ""
  337.        t = AskLine("Rename", StrCat(s, @CRLF, @CRLF, "to"), t)
  338.        If t == "" Then Message("Rename Error", "Cannot rename to null file name")
  339.                   Then Exit
  340.        FileRename(s, t)
  341.  
  342.   
  343. Clipboard Tricks ; Copies just the filenames to the clipboard
  344.  FileName(s) to Clipboard ; Just the filenames
  345.     a=FileItemize("")
  346.         a=ItemSort(a,@tab)
  347.         a=strreplace(a,@TAB,@CRLF)
  348.     ClipPut(a)
  349.         Display(2,"Filenames placed on Clipboard",a)
  350.  Path and FileName(s) to Clipboard ; Copies filenames with full paths to the Clipboard
  351.         a=FileItemize("")
  352.         a=ItemSort(a,@TAB)
  353.     a=strcat(@TAB,StrSub(a,1,strlen(a)-1))
  354.     b=DirGet()
  355.     a=StrSub(StrReplace(a,@TAB,strcat(@TAB,b)),2,-1)
  356.     a=StrReplace(a,@TAB,@CRLF)
  357.     ClipPut(a)
  358.         Display(2,"Full path filenames placed on Clipboard",a)
  359.  Path to Clipboard   ; Copies just the path to the clipboard
  360.         a=DirGet()
  361.         ClipPut(a)
  362.         Display(2,"Path placed on Clipboard",a)
  363.     
  364.     
  365.  _Run Clipboard Viewer   ; Lets you see what is on the clipboard
  366.     Run("clipbd.exe","")
  367.  
  368.  
  369. WIL Interactive
  370.  Execute a function
  371.         call("%homedir%wwwmenu95.wil","CMDSTACK NEWCMD")
  372.  _Load WIL Help File
  373.     WinHelp(strcat(wbdir,"Windows Interface Language.hlp"),"CONTENTS","")     
  374.       
  375.  
  376.  
  377.      
  378. _Edit File Menus ; Modify WinBatch FileMenus here 
  379.  Edit menu for this filetype  ; Edit menus for files with a specific file extension.
  380.         b=strupper(FileExtension(CurrentFile()))
  381.         a=IniReadPvt("Menus",b,"*NONE*",inifile)
  382.         if a=="*NONE*" then a=strcat("FileMenu for %b% files",".mnw")
  383.         if FilePath(a)=="" then a=strcat(HomeDir,a)
  384.         ;Message(a,FileExist(a))
  385.         if !(FileExist(a))
  386.                 c=AskYesNo("Please note:","The menu file for the %b% filetype does not exist.  Would you like to start a new one?")
  387.                 if c==@NO then exit
  388.                 c=               "; WinBatch FileMenu for %b% filetype%@CRLF%"
  389.                 c=strcat(c,@CRLF,"; This is a sample menu file to help you get started")
  390.                 c=strcat(c,@CRLF,"; writing your very own Winbatch FileMenu menus.  It is")
  391.                 c=strcat(c,@CRLF,"; really not too bad.  WinBatch is a simple programming")
  392.                 c=strcat(c,@CRLF,"; language.  You can find out just about all you need to")
  393.                 c=strcat(c,@CRLF,"; know from the Windows Interface Language help file or")
  394.                 c=strcat(c,@CRLF,"; the manual.  Check out the section on Menu Files,")
  395.                 c=strcat(c,@CRLF,"; the WIL Tutorial and the WIL Function Reference.")
  396.  
  397.                 c=strcat(c,@CRLF,@CRLF,'Standalone menu item            ; Sample menu item')
  398.                 c=strcat(c,@CRLF,      '        Message("Hello","There")')
  399.                 c=strcat(c,@CRLF,@CRLF,'Top Level menu item')
  400.                 c=strcat(c,@CRLF,      ' Selected File is               ; Shows currently selected file')
  401.                 c=strcat(c,@CRLF,      '        a=CurrFilePath()')
  402.                 c=strcat(c,@CRLF,      '        Message("Selected File is",a)')
  403.                 c=strcat(c,@CRLF,      ' Run Calculator                 ; Sample Run function')
  404.                 c=strcat(c,@CRLF,      '        Run("calc.exe","")')
  405.                 c=strcat(c,@CRLF,      ' Run Notepad on selected file   ; Sample Run function with filename')
  406.                 c=strcat(c,@CRLF,      '        a=CurrFilePath()')
  407.                 c=strcat(c,@CRLF,      '        Run("notepad.exe",a)')
  408.  
  409.                 c=strcat(c,@CRLF,@CRLF,'; Note: You may want to delete this menu item if you edit this file')
  410.                 c=strcat(c,@CRLF,      ' _Delete this sample menu file  ; Deletes this menu file')
  411.  
  412.                 c=strcat(c,@CRLF,      '        inifile=strcat(DirWindows(0),"FileMenu.ini")')
  413.                 c=strcat(c,@CRLF,      '        if !FileExist(inifile) then inifile=strcat(homedir,"FileMenu.ini")')
  414.  
  415.  
  416.                 c=strcat(c,@CRLF,      '        b=strupper(FileExtension(CurrentFile()))')
  417.                 c=strcat(c,@CRLF,      '        a=IniReadPvt("Menus",b,"*NONE*",inifile)')
  418.                 c=strcat(c,@CRLF,      '        if a=="*NONE*" then a=strcat("FileMenu for %b% files",".mnw")')
  419.                 c=strcat(c,@CRLF,      '        if FilePath(a)=="" then a=strcat(HomeDir,a)')
  420.                 c=strcat(c,@CRLF,      '        c=AskYesNo("Are you sure you wish to delete this menu file",a)')
  421.                 c=strcat(c,@CRLF,      '        if c==@YES')
  422.                 c=strcat(c,@CRLF,      '           IniDeletePvt("Menus",b,inifile)')
  423.                 c=strcat(c,@CRLF,      '           FileDelete(a)')
  424.                 c=strcat(c,@CRLF,      '        endif')
  425.  
  426.  
  427.  
  428.  
  429.                 c=strcat(c,@CRLF)
  430.                 fh=FileOpen(a,"WRITE")
  431.                 FileWrite(fh,c)
  432.                 FileClose(fh)
  433.                 iniwritepvt("Menus",b,a,inifile)
  434.                 drop(c)
  435.                 
  436.         endif
  437.         Run(Editor,a)
  438.  ;Edit the Miscellaneous File Menu     ; Edit menus for files with unrecognized extensions
  439.  ;       a=IniReadPvt("FileMenu","DefaultMenu",defaultmenu,inifile)
  440.  ;       a=strcat(HomeDir,a)
  441.  ;       Run(Editor,a)
  442.  Edit menu for all filetypes      ; Edit global menu for all files 
  443.         a=IniReadPvt("FileMenu","CommonMenu",commonmenu,inifile)
  444.         a=strcat(HomeDir,a)
  445.         Run(Editor,a) 
  446.  _Load WIL Help File
  447.     WinHelp(strcat(wbdir,"Windows Interface Language.hlp"),"CONTENTS","")     
  448.  
  449.  _About WinBatch FileMenu  ; Software from Wilson WindowWare
  450.         About()           
  451.            
  452.